/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.stakeholder;

import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import session.stateless.StakeholderUnstructuredContentSessionBean;
import session.stateless.SystemMessagesBean;
import util.localization.WebLocalization;

/**
 *
 * @author WenYong
 */
@ManagedBean(name = "addUnstructuredContentManager")
@RequestScoped
public class AddUnstructuredContentManager {

    private String nextPage;
    private Long stakeholderId;
    @EJB
    private SystemMessagesBean systemMessages;
    private String preferredLocale;
    private FacesContext ctx = FacesContext.getCurrentInstance();
    private WebLocalization localization;
    @EJB
    private StakeholderUnstructuredContentSessionBean unstructuredContentSession;

    public AddUnstructuredContentManager() throws KeyStoreException {
        localization = new WebLocalization();
        preferredLocale = localization.getPreferredLocaleFromSession();
        KeyStore.getInstance("JKS");

        stakeholderId = (Long) ctx.getExternalContext().getSessionMap().get("stakeholderId");

        if (stakeholderId == null) {

            nextPage = (ctx.getExternalContext().encodeActionURL(FacesContext.getCurrentInstance().getApplication().getViewHandler().getActionURL(FacesContext.getCurrentInstance(), "/StakeholderLogin.xhtml")));
            try {
                ctx.getExternalContext().redirect(nextPage);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }

    public void TemplateOneSelected() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("TemplateSelected", 1);
        FacesContext.getCurrentInstance().getExternalContext().redirect("addUnstructuredContentTemplateElements.xhtml");
    }

    public void TemplateTwoSelected() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("TemplateSelected", 2);
        FacesContext.getCurrentInstance().getExternalContext().redirect("addUnstructuredContentTemplateElements.xhtml");
    }

    public void TemplateThreeSelected() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("TemplateSelected", 3);
        FacesContext.getCurrentInstance().getExternalContext().redirect("addUnstructuredContentTemplateElements.xhtml");
    }

    public void TemplateFourSelected() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("TemplateSelected", 4);
        FacesContext.getCurrentInstance().getExternalContext().redirect("addUnstructuredContentTemplateElements.xhtml");
    }

    public void TemplateFiveSelected() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("TemplateSelected", 5);
        FacesContext.getCurrentInstance().getExternalContext().redirect("addUnstructuredContentTemplateElements.xhtml");
    }

    public void TemplateSixSelected() throws IOException {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("TemplateSelected", 6);
        FacesContext.getCurrentInstance().getExternalContext().redirect("addUnstructuredContentTemplateElements.xhtml");
    }
}
